package com.example.groupmeal.service;

import com.example.groupmeal.dao.TmsBannerMapper;
import com.example.groupmeal.entity.TmsBanner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/*
 * 轮播广告服务接口
 */
@Service
public class BannerService {

	@Autowired
	private TmsBannerMapper bannerMapper;

	/**
	 * 查询可用的banner
	 * @param type  1 员工版  2 客户版
	 * @return
	 */
	public List<TmsBanner> getBannerInfo(Byte type) {
		return bannerMapper.findAllByTypeAndStatus(type, (byte)1);
	}

	/**
	 * 测试重复提交拦截
	 * @param
	 * @return
	 */
	public Integer addBannerInfo() {
		TmsBanner banner = new TmsBanner();
		banner.setImg("http://121.43.100.16:8085/static/image/1573626123590.jpg");
		banner.setType((byte)2);
		banner.setStatus((byte)1);
		banner.setCreateTime(new Date());
		return bannerMapper.insert(banner);
	}
	
}